Hexo部署博客的err

错误1

在使用hexo部署博客到gitcafe的时候,出现了如下错误:

1
2
3
4
5
6
7
8
9
10
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
fatal: Not a git repository (or any of the parent directories): .git
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: fatal: Not a git repository (or any of the parent directories): .git
at ChildProcess.<anonymous> (E:\blog\HexoBlog\node_modules\hexo-util\lib\spawn.js:37:17)
at emitTwo (events.js:87:13)
……

解决方法

1
2
删除.deploy文件夹,重新生成即可解决该问题
哈哈哈,抖机灵。成功。

权限错误

1
2
3
4
5
6
7
8
9
10
11
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights

有网友们有建议将deploy处设置不要使用https,而是改为SSH,如下:

1
repository: https://github.com/username/username.github.io.git

修改为:

1
repo:git@github.com:username/username.github.io.git

各种姿势修改都不对,究竟怎样使我们的博客可以重新部署到github上

当部署失败的时候,请按照以下步骤进行:

1.检查是否有SSH key

登陆github,点击头像位置处 Settings ——> SSH and GPG keys ,查看是否有SSH keys。如果有,直接跳到第(3)步;如果没有,则继续。

2.新建 SSH key,在git shell(或者git bash等命令窗口),注意大小写:

1
$ ssh-keygen -t rsa -C "邮箱名"

然后出现:

1
2
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dell/.ssh/id_rsa):

直接回车就可以。
然后会出现:

1
2
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

要求你输入密码,这个密码会在你提交项目时使用,如果为空的话提交项目时则不用输入。这个设置是防止别人往你的项目里提交内容。

注意:输入密码的时候没有*字样的,直接输入就好。
然后会出现:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Your identification has been saved in /c/Users/dell/.ssh/id_rsa.
Your public key has been saved in /c/Users/dell/.ssh/id_rsa.pub.
The key fingerprint is:
65:69:······02:4b emailname@email.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . o . |
| . o o = o |
| . o * = o |
| E o + o . |
| . o. . . |
| .. |
+-----------------+

至此,密钥已经成功生成

接下来在github上添加SSH key:

① 打开本地文件:id_rsa.pub(文件路径可以在上一步SSH生成成功后看到路径,比如我的是c/Users/dell/.ssh/id_rsa.pub),可以将这个文件在编辑器中打开,然后全选复制。

② 登陆github,点击头像位置处 Settings ——> SSH and GPG keys ——> New SSH key,点击新建SSH key。

③ 将 ① 中复制的内容粘贴在key文本框里,title可以不用填(或者自己起一个名字也可以)。

4.测试设置是否成功:

1
$ ssh -T git@github.com

出现:

1
2
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

5.设置用户信息:

1
2
$ git config --global user.name "用户名"
$ git config --global user.email "你希望的邮箱名"

6.然后就可以部署你的博客到github了

1
2
$ hexo g
$ hexo d

结束...